import { inject, observer } from 'mobx-react';
import { toJS } from "mobx"
import { WeaLocaleProvider } from 'ecCom'
import CommentMain from '../dialog/main';
const getLabel = WeaLocaleProvider.getLabel;

@inject("checkMatterStore")
@observer
export default class WorkReport extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            topHeight: 0,
            tab: [`${getLabel('18329', '领导批示')}`],
            comment: [`${getLabel('675', '评论')}`]
        }
    }
    componentDidMount = () => {
        const { checkMatterStore, id } = this.props;
        let { pageindex, pagesize } = checkMatterStore;
        checkMatterStore.getTaskId(id);
        checkMatterStore.init({ "taskId": id, "pageindex": pageindex, "pagesize": pagesize });
        checkMatterStore.status.WeaRichTextStoreValue = {};
    }

    componentWillReceiveProps(newProps) {
        if(newProps.loading){
            if (newProps.id != '' && newProps.id != this.props.id) {
                let { checkMatterStore, id } = newProps;
                let { pageindex, pagesize } = checkMatterStore;
                checkMatterStore.getTaskId(id);
                checkMatterStore.init({ "taskId": id, "pageindex": pageindex, "pagesize": pagesize });
            }
        }
    }

    render() {
        const { checkMatterStore } = this.props;
        const { userInfo, weiboCKEditorConfig, basicInfo, weiboList, systemWorkLog, weiboGroup, fanList, attentionList, defaultTemplate, keyWords, loading } = toJS(this.props.checkMatterStore.status),
            { topHeight, attentionCheck, currentGroup, isReset, tab, comment } = this.state;
        return (
            <div className=''>
                <CommentMain ecId={`${this && this.props && this.props.ecId || ''}_CommentMain@m0ltm8`}
                    ref="rightContainer"
                    checkAttention={this.checkAttention}
                    changeGroup={this.changeGroup}
                    topHeight={topHeight}
                    userInfo={userInfo}
                    weiboGroup={weiboGroup}
                    weiboList={weiboList}
                    basicInfo={basicInfo}
                    fanList={fanList}
                    defaultTemplate={defaultTemplate}
                    attentionList={attentionList}
                    systemWorkLog={systemWorkLog}
                    weiboCKEditorConfig={weiboCKEditorConfig}
                    changeReset={this.changeReset}
                    keyWords={keyWords}
                    loading={loading}
                    tab={tab}
                    comment={comment}
                    showSlideEdit={false}
                    defaultHeight={520}
                />
            </div>
        )
    }
    checkAttention = (value) => {
        this.setState({ attentionCheck: value })
    }
    changeGroup = (value) => {
        this.setState({ currentGroup: value.groupId })
    }
    changeReset = (value) => {
        this.setState({ isReset: value })
    }
}
